package thread;

/**
 * 获取线程信息的相关方法
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();//获取主线程
        String name =main.getName();
        System.out.println("名字"+name);

        long id = main.getId(); //获取唯一标识
        System.out.println("唯一标识："+id);

        int prioity = main.getPriority();  //获取优先级
        System.out.println("获取优先级："+prioity);

        boolean isAlive = main.isAlive();  //是否活着
        System.out.println("是否活着："+isAlive);

        boolean isInterrupted = main.isInterrupted();//是否被中断
        System.out.println("是否被中断了："+isInterrupted);
    }
}
